package io.renren.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.sys.dao.JxStudentHomworkDao;
import io.renren.modules.sys.entity.JxStudentHomworkEntity;
import io.renren.modules.sys.service.JxStudentHomworkService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("jxStudentHomworkService")
public class JxStudentHomworkServiceImpl extends ServiceImpl<JxStudentHomworkDao, JxStudentHomworkEntity> implements JxStudentHomworkService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<JxStudentHomworkEntity> page = this.page(
                new Query<JxStudentHomworkEntity>().getPage(params),
                new QueryWrapper<JxStudentHomworkEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils getAllWithPage(Map<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("page").toString()),Integer.parseInt(params.get("limit").toString()));
        List<JxStudentHomworkEntity> list = this.baseMapper.getAllWithPage(params);
        PageInfo<JxStudentHomworkEntity> pageInfo = new PageInfo<JxStudentHomworkEntity>(list);
        return new PageUtils(list,(int)pageInfo.getTotal(),pageInfo.getPageSize(),pageInfo.getPageNum());
    }
}
